package forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;

public class FileUploadForm extends ActionForm {

	// ====== Form variables ====== //
	private FormFile myFile;

	// ======= Getters and Setter ===== //	
	public void setMyFile(FormFile myFile) {
		this.myFile = myFile;
	}

	public FormFile getMyFile() {
		return myFile;
	}

	/**
	 * reset
	 * 
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		this.setMyFile(null);
	}
	
	/**
	 * validate
	 * 
	 */
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {
		
		ActionErrors errors = new ActionErrors();
		
		if (myFile == null) {
			errors.add("fileMsgTag1", new ActionMessage("errors.file"));
		}
		
		return errors;
	}
}